Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Language Guide / Part 2 - AppleScript Language Reference
Chapter 6 - Expressions / Operations
Operators That Handle Operands of Various Classes


Contains, Is Contained By

The Contains and Is Contained By operators work with lists, records,
and strings.

LIST
A list contains another list if the list to the right of the operator is a sublist
of the list to the left of the operator. A sublist is a list whose items appear in
the same order and have the same values as any series of items in the other list. For example,

{ "this", "is", 1 + 1, "cool" } contains { "is", 2 }
is true, but

{ "this", "is", 2, "cool" } contains { 2, "is" }
is false.

A list is contained by another list if the list to the left of the operator is a sublist of the list to the right of the operator. For example,

{ "is", 2} is contained by { "this", "is", 2, "cool" } 
is true. Both Contains and Is Contained By work if the sublist is a single value. For example,

{ "this", "is", 2, "cool" } contains 2
and

2 is contained by { "this", "is", 2, "cool" }
are true.

RECORD
A record contains another record if all the properties in the record to the
right of the operator are included in the record to the left, and the values
of properties in the record to the right are equal to the values of the corresponding properties in the record to the left. A record is contained by another record if all the properties in the record to the left of the operator are included in the record to the right, and the values of the properties in the record to the left
are equal to the values of the corresponding properties in the record to the right. The order in which the properties appear does not matter. For example,

{ name:"Eric", mileage:"8000", description:"fast"} ÿ   contains { description:"fast", name:"Eric" }
is true.

STRING
A string contains another string if the characters in the string to the right of the operator are equal to any contiguous series of characters in the string to the left of the operator. For example,

"operand" contains "era"
is true, but

"operand" contains "dna"
is false.

A string is contained by another string if the characters in the string to the left of the operator are equal to any series of characters in the string to the right of the operator. For example, this statement is true:

"era" is contained by "operand"

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996